package com.monkeygroup.mygoplus.view.home.activity.person;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.monkeygroup.mygoplus.R;
import com.monkeygroup.mygoplus.base.BaseActivity;
import com.monkeygroup.mygoplus.view.entrance.activity.RegisterPrivacyActivity;

import java.util.ArrayList;
import java.util.List;

/**
 * 關於我們
 * Created by cumt on 2017/6/27.
 */

public class PersonAboutUsActivity extends BaseActivity implements View.OnClickListener {

    public static void gotoActivity(Activity activity) {
        Intent intent = new Intent(activity,
                PersonAboutUsActivity.class);

        activity.startActivity(intent);
    }

    private Activity activity;
    private ImageView imgBack,img_right;
    private TextView txtTitle;
    private LinearLayout layout_shortcut;

    private ListView publish_about_list;

    private LeftAdapter adapter;
    private List<String> leftListItems;
    @Override
    public void onClick(View v) {

    }

    @Override
    public void setContentView() {
        setContentView(R.layout.person_about);
    }

    @Override
    public void initView() {

        activity = PersonAboutUsActivity.this;
        imgBack = (ImageView) findViewById(R.id.img_back);
        imgBack.setVisibility(View.INVISIBLE);
        txtTitle = (TextView) findViewById(R.id.txt_title);
        txtTitle.setText("關於MyGo");
        img_right= (ImageView) findViewById(R.id.img_right);
        img_right.setImageResource(R.mipmap.btn_me_close3x);
        layout_shortcut= (LinearLayout) findViewById(R.id.layout_shortcut);
        layout_shortcut.setVisibility(View.VISIBLE);


        publish_about_list = (ListView)findViewById(R.id.publish_about_list);


        leftListItems = new ArrayList<>();
        leftListItems.add("公司介紹");
        leftListItems.add("服務條款");
        leftListItems.add("隱私權政策");
        leftListItems.add("著作權財產聲明");
        leftListItems.add("智慧財產權檢舉辦法");

        adapter = new LeftAdapter(PersonAboutUsActivity.this);
        publish_about_list.setAdapter(adapter);

    }

    @Override
    public void setListener() {

    }

    @Override
    public void doEvent() {
        imgBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

    }

    public class LeftAdapter extends BaseAdapter {


        private LayoutInflater mInflater;


        public LeftAdapter(Context context) {
            this.mInflater = LayoutInflater.from(context);
        }

        @Override
        public int getCount() {
            return leftListItems.size();
        }

        @Override
        public Object getItem(int position) {
            return leftListItems.get(position);
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(final int position, View myconvertView, ViewGroup parent) {

            View leftconvertView = mInflater.inflate(R.layout.published_second_item, null);
            final TextView txtName = (TextView) leftconvertView
                    .findViewById(R.id.txt_publish_content);
            txtName.setText(leftListItems.get(position));


            leftconvertView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    if(position==1){
                        RegisterPrivacyActivity.gotoActivity(activity,1);
                    }

                    else if(position==2){
                        RegisterPrivacyActivity.gotoActivity(activity,2);



                    }

                }
            });

            return leftconvertView;
        }

    }
}
